//
//  firstTouchCell.m
//  EMMApp
//
//  Created by 无常先生 on 2018/8/20.
//  Copyright © 2018年 YiXun. All rights reserved.
//

#import "firstTouchCell.h"
#import "UIView+Extension.h"
#import "UIButton+ImageTitleSpacing.h"

@interface firstTouchCell ()
@property (nonatomic,weak) UILabel *flagLable;
@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UIButton *rightArrow;

@end

@implementation firstTouchCell

- (void)awakeFromNib {
    [super awakeFromNib];

    UILabel *flagView = [[UILabel alloc]init];
    flagView.text = @"*";
    flagView.font = [UIFont systemFontOfSize:13];
    flagView.textColor = [UIColor redColor];
    [self.contentView addSubview:flagView];
    self.flagLable = flagView;
    
    UILabel *titlelable = [[UILabel alloc]init];
    [self.contentView addSubview:titlelable];
    titlelable.text = @"接触方式";
    titlelable.font = [UIFont systemFontOfSize:15];
    self.titleLabel = titlelable;
    
    UIButton *arrowBtn = [[UIButton alloc]init];
    [self.contentView addSubview:arrowBtn];
    [arrowBtn setTitle:@"请选择" forState:UIControlStateNormal];
    [arrowBtn setTitleColor:[UIColor colorFromHexCode:@"#999999"] forState:UIControlStateNormal];
    [arrowBtn setImage:[UIImage imageNamed:@"arrow_left"] forState:UIControlStateNormal];
    [arrowBtn addTarget:self action:@selector(arrowAction:) forControlEvents:UIControlEventTouchUpInside];
    self.rightArrow = arrowBtn;
    [arrowBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:15];
    

}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.flagLable.frame = CGRectMake(10, 0, 10, 10);
    self.flagLable.centerY = self.contentView.centerY;
    
    self.titleLabel.frame = CGRectMake(self.flagLable.x + self.flagLable.width, 0, 85, 35);
    self.titleLabel.centerY = self.flagLable.centerY;
    
    self.rightArrow.frame = CGRectMake(self.width - 100, 0, 90, 35);
    self.rightArrow.centerY = self.contentView.centerY;
    
    
}


- (void)arrowAction:(UIButton *)btn {
    //1、今天（默认）；2、昨天；3、本周；4、上周；5、本月；6、上月；7、近三月；8、今年
    NSArray *arr = [NSArray arrayWithObjects:
                    @"来电",@"来访",@"电转访",nil];
    ShowMenuView *menuView = [[ShowMenuView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) title:@"选项" titleNmae:@"接触方式" numLits:nil items:arr];
    menuView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    [[UIApplication sharedApplication].keyWindow addSubview:menuView];
    __block ShowMenuView *weakMenuView = menuView;

    [menuView setTouchBlock:^(NSString *indet,NSString *number) {
        
        [weakMenuView removeFromSuperview];
    }];
    
}


@end
